<template>
  <view class="content">
    <uni-nav-bar title="会员列表" fixed :border="false" height="88rpx" left-icon="left" @clickLeft="onClickLeft"
      statusBar></uni-nav-bar>
    <!-- <view class="safe-area" :style="{ height: statusBarHeight + 'px' }" style="width: 100%;"></view> -->
    <!-- <view class="main" style="flex:1;"> -->
    <scroll-view class="scroll-view_H" scroll-y @refresherrefresh="refresherrefreshFn" refresher-enabled="true"
      :show-scrollbar="false" @scrolltolower="lower" :refresher-triggered="triggered" enhanced
      :style="{ height: `calc(100vh - 88rpx - ${statusBarHeight}px)` }">
      <view class="infoCard" v-for="item in memberList" :key="item.id">
        <!-- <image :src="item.headImg" mode="aspectFit" class="goodsImg"></image> -->
        <image :src="item.headImg ? item.headImg : '/static/index/noneImg.png'" mode="aspectFill" class="goodsImg">
        </image>
        <view class="info">
          <view class="name">会员名称：{{ item.name == 'noname' || !item.name ? item.phone : item.name }}</view>
          <view class="phone">手机号码：{{ item.phone }}</view>
          <view class="tokenNum">
            <view class="count" style="margin-right: 80rpx;">数字资产：{{ item.tokenNum }}</view>
            <view class="count">核销次数：{{ item.exchangeCount }}</view>
          </view>
          <view class="count">注册时间：{{ item.createTime | parseTime }}</view>
        </view>
      </view>
      <uni-load-more :status="loading" v-if="memberList.length > 0"></uni-load-more>
      <view
        style="width: 100%;height: 100%;background-color: #f7f7f7;display: flex;justify-content: center;align-items: center;"
        v-if="memberList.length == 0">
        <image src="/static/index/nonedata.png" mode="aspectFill" style="width: 400rpx;height: 400rpx;"></image>
      </view>
    </scroll-view>
    <!-- </view> -->
  </view>
</template>

<script>
import { reqMeneberList } from '@/apis/member.js'
export default {
  name: "MemberInfo",
  data() {
    return {
      memberList: [],
      page: {
        pageNum: 1,
        pageSize: 15
      },
      triggered: false, // 是否触发下拉刷新
      loading: 'loading', // 是否触发上拉加载
    }
  },
  onLoad() {
    this.getMemberList()
  },
  onShow() {
  },
  methods: {
    refresherrefreshFn() {
      this.page.pageNum = 1
      this.triggered = true
      this.memberList = []
      this.loading = "loading";
      this.getMemberList();
    },
    async getMemberList() {
      const res = await reqMeneberList({ ...this.page })
      if (res.code === 200) {
        this.memberList = [...this.memberList, ...res.data.list]
        this.nextPage = res.data.nextPage
        console.log('memberList:', this.memberList);
        this.triggered = false
        if (res.data.isLastPage) {
          this.loading = "noMore"
        }
      }
    },
    lower() {
      if (this.loading == "noMore") {
        return;
      }
      this.page.pageNum++;
      this.loading = "loading";
      this.getMemberList();
    },
  }
}
</script>

<style>
page {
  background: #d3e3fd;

}
</style>
<style lang="scss" scoped >
.content {
  height: 100%;
  background-color: #d3e3fd;
  display: flex;
  flex-direction: column;
}

view {
  box-sizing: border-box;
}

.infoCard {
  display: flex;
  font-size: 26rpx;
  margin: 20rpx;
  padding: 20rpx 20rpx;
  align-items: center;
  height: 240rpx;
  line-height: 50rpx;
  border-radius: 20rpx;
  background-color: #fff;
  // border: 1px solid #619cfc;

  .goodsImg {
    margin-right: 20rpx;
    width: 180rpx;
    height: 180rpx;
    border-radius: 50%;
    background-color: #eee;
  }

  .info {
    flex: 1;
  }

  .tokenNum {
    display: flex;
    width: 100%;
    // justify-content: space-between;
  }
}
</style>
